<?php
// 验证码
    session_start();
    header('content-type:image/jpeg');
    $img = imagecreate(98,40);
    $bgColor = imagecolorallocate($img,220,220,220);
    $sstr = '';
    for ($i=0; $i < 4; $i++) {
        $str = rand(0,9);
        $sstr .= $str;
        $fontColor = imagecolorallocate($img, rand(0,255),rand(0,255),rand(0,255));
        imagettftext($img, 30, 0, $i*25, 30, $fontColor, '../font/xm.ttf', $str);
    }
    for ($i=0; $i < 5000; $i++) {
        $tColor = imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));
        imagesetpixel($img, 0, 0, $tColor);
    }

    imagejpeg($img);
    $_SESSION['veri'] = $sstr;

 ?>